//
//  HHTagListView.h
//
//  Created by Basic on 15/1/12.
//  Copyright (c) 2015 Basic. All rights reserved.
//  标签view
//  intrinsicContentSize 返回实时高度

#import <UIKit/UIKit.h>
#import "HHTagItemProtocol.h"
#import "HHTagListConfig.h"
#import "HHTagButton.h"

NS_ASSUME_NONNULL_BEGIN

@class HHTagListView;
@protocol HHTagListViewDelegate <NSObject>

@required

///  返回数据源
/// @param listView listView description
-(NSArray<id<HHTagItemProtocol> > *)hh_TagListViewDataSource:(HHTagListView *)listView;

@optional
///  tag item 即将展现
/// @param listView listView description
/// @param tag tag description
-(void)hh_TagListView:(HHTagListView *)listView willDisplayTag:(HHTagButton  *)tag;


/// 当前tag是否可以主动点击选中
/// @param listView listView description
/// @param tag tag description
-(BOOL)hh_TagListView:(HHTagListView *)listView shouldSelectTag:(HHTagButton  *)tag;

/// 选中某个 tag事件
/// @param listView listView description
/// @param selectedTag 选中的标签
/// @param cancelTags 取消标签列表
/// @param isGesture 是否手势触发
-(void)hh_TagListView:(HHTagListView *)listView didSelectTag:(id<HHTagItemProtocol>  )selectedTag withCancelTags:(NSArray<id<HHTagItemProtocol>> *_Nullable)cancelTags withGesture:(BOOL )isGesture;

@end


@interface HHTagListView : UIView
/** delegate */
@property (weak, nonatomic, nullable) id<HHTagListViewDelegate> delegate;
/** 配置模型，默认配置见 HHTagListConfig.h */
@property (strong, nonatomic, readonly) HHTagListConfig *config;
/** 选中的tags */
@property (strong, nonatomic, readonly) NSArray<id<HHTagItemProtocol> > *selectTags;//选择的tags

//MARK: - 刷新数据
/// 刷新数据
-(void)reloadData;

//MARK: - 选中标签、取消选中标签
/// 根据tagModel 选择tag
- (void)selectTag:(id<HHTagItemProtocol> )tagModel;
/// 根据uniqueId 选择tag
- (void)selectTagWithUniqueId:(NSNumber *_Nullable)uniqueId;
/// 根据tagModel 取消选择的标签
- (void)deselectTag:(id<HHTagItemProtocol> )tagModel;
/// 取消所有选择的标签
- (void)deselectAllTags;

//MARK: - 计算size
/**
 根据标签text 数组、标签配置，计算标签size

 @param tags 标签text 数组
 @param config 标签配置
 @return 实际size
 */
+(CGSize )intrinsicContentSize:(NSArray<NSString *> *)tags withConfig:(HHTagListConfig *)config;

/**
 根据标签text 字典数组、标签配置，计算标签size

 @param textDicts 标签 字典数组
 @param textBlock 根据数组获取 text block，必须
 @param config 标签配置
 @return return value description
 */
+(CGSize )intrinsicContentSize:(NSArray<NSDictionary *> *)textDicts withBlock:(NSString *(^_Nullable)(NSDictionary *textDict) )textBlock withConfig:(HHTagListConfig *)config;
/**
 根据标签数据源数组、标签配置，计算标签size
 
 @param tags 标签数据源数组
 @param config 标签配置
 @return 实际size
 */
+(CGSize )intrinsicContentSizeWithTags:(NSArray<id<HHTagItemProtocol> > *)tags withConfig:(HHTagListConfig *)config;
@end

NS_ASSUME_NONNULL_END
